package com.totoro.mysql;

public class TimerLogger {
    //private static final Logger logger = LoggerFactory.getLogger(TimerLogger.class) ;
    private  static ThreadLocal<TimerLogger> threadLocal = new ThreadLocal<>() ;

    private long start = 0l ;

    public static TimerLogger getInstance(){
        TimerLogger timerLogger = threadLocal.get() ;
        if(timerLogger == null){
            timerLogger = new TimerLogger() ;
            threadLocal.set(timerLogger);
        }
        return timerLogger ;
    }

    public  void start(){
        start = System.currentTimeMillis() ;
    }

    public void end(String msg){
        System.out.println(msg.concat("cost:").concat((System.currentTimeMillis() - start)+"ms" ));
    }
}
